#include <iostream>
#include <algorithm> 

#define num 8
int Points[2][num] = {
//  0,1,2,3,4,5,6,7
	1,1,0,1,0,0,0,1,
	0,0,0,0,0,0,0,0
};

using namespace std;

int main() {
	int used = 0;
	int len = 0;
	
	for(int dis = 1; dis < num; dis++){
		
		if(used == num) break;
		
		for(int i = 0; i < 8 - dis; i++){
			if(Points[1][i] == 0 && Points[1][i+dis] == 0 
			&& (Points[0][i] != Points[0][i+dis])){
				Points[1][i] = 1;
				Points[1][i+dis] = 1;
				used += 2;
				len += dis;
				
				cout << "i="<<i <<" dis="<< dis <<" len="<< len<<endl; 
			}
		}
	}
	
	cout << len <<endl;
    return 0;
}
